package com.calm.cdemo;

import android.content.Intent;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.calm.cdemo.activitytransition.TransitionActivityMenu;
import com.calm.cdemo.anim.AnimMenu;
import com.calm.cdemo.base.BaseActivity;
import com.calm.cdemo.bean.MenuBean;
import com.calm.cdemo.myview.MyViewMenu;
import com.calm.cdemo.swipeback.And_SwipeBack;
import com.calm.cdemo.swipeback.SwipeBackLayoutActivity;
import com.calm.clibrary.rvadapter.CommRvAdapter;
import com.calm.clibrary.rvadapter.CommRvHolder;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.AccessMode;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void init() {
        Log.e("CALM",CLASS);
        setBackVisiable(View.GONE);
        RecyclerView rvList = findViewById(R.id.main_rv_list);
        rvList.setLayoutManager(new LinearLayoutManager(this));
        rvList.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
        CommRvAdapter<MenuBean> adapter = new CommRvAdapter<MenuBean>(this,getMenuList(),R.layout.main_item) {
            @Override
            public void bindData(CommRvHolder holder, final MenuBean data, int position) {
                TextView tvName = holder.getViw(R.id.main_item_tv_name);
                tvName.setText(data.name);
                holder.setCommRvOnItemClickListener(new CommRvHolder.CommRvOnItemClickListener() {
                    @Override
                    public void onItemClickListener(int position) {
//                        if(position == 4){
//                            read();
//                            return;
//                        }
                        startActivity(new Intent(mActivity,data.toClass));

                    }
                });
            }
        };
        rvList.setAdapter(adapter);
    }
    private List<MenuBean> getMenuList(){
        List<MenuBean> menus = new ArrayList<>();
        MenuBean b0 = new MenuBean();
        b0.name = "Activity转场动画";
        b0.toClass = TransitionActivityMenu.class;
        b0.description = "转场动画菜单";
        menus.add(b0);
        MenuBean b1 = new MenuBean();
        b1.name = "滑动返回(SwipeBackLayout)";
        b1.toClass = SwipeBackLayoutActivity.class;
        b1.description = "滑动返回示例,使用SwipeBackLayout库";
        menus.add(b1);
        MenuBean b2 = new MenuBean();
        b2.name = "滑动返回(AndSwipeBack)";
        b2.toClass = And_SwipeBack.class;
        b2.description = "滑动返回示例,AndSwipeBack";
        menus.add(b2);
        MenuBean b3 = new MenuBean();
        b3.name = "Android动画";
        b3.toClass = AnimMenu.class;
        b3.description = "Android动画，1.0开始的补间动画和3.0引入的属性动画";
        menus.add(b3);
        MenuBean b4 = new MenuBean();
        b4.name = "自定义View";
        b4.toClass = MyViewMenu.class;
        b4.description = "自定义View系列";
        menus.add(b4);
        return menus;
    }
}
